﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminFunction.Master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="BitPortal.Admin.Services.Error.Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .x-grid3-cell-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        
        .x-grid-group-hd div
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        
        .x-grid3-hd-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
            font-size: 12px;
        }
        
        .x-grid3-body .x-grid3-td-Cost
        {
            background-color: #f1f2f4;
        }
        
        .x-grid3-summary-row .x-grid3-td-Cost
        {
            background-color: #e1e2e4;
        }
        
        .x-label-text
        {
            font-weight: bold;
            font-size: 11px;
        }
    </style>
    <style type="text/css">
        .attachlink
        {
            text-decoration: none;
            line-height: 18px;
        }
        .attachlink img
        {
            margin: 0 1px -6px 0;
        }
    </style>
    <script type="text/javascript">

        var LoadAttachs = function (value) {
            var template = "";
            var arr = value.split("#");
            for (var i = 0; i < arr.length; i++) {
                if (arr[i].length > 0) {
                    var name = arr[i].substring(arr[i].lastIndexOf('/') + 1);
                    template += '<a class="attachlink" href="' + arr[i] + '" target="_blank" title="' + name + '" ><img src="/Images/rar_32.png" width="16" alt="' + name + '" />' + name + '</a><br/>';
                }
            }
            return template;
        };

        
        var LoadState = function (value) {
            var returnValue = "";
            switch (value) {
                case 1: returnValue = "Chưa duyệt";
                    break;
                case 2: returnValue = "Đã duyệt";
                    break;
                case 3: returnValue = "Đã hoàn thành";
                    break;
            }
            return returnValue;
        }

        var template = '<span style="color:{0};">{1}</span>';

        var LoadColor = function (value) {
            if (value == 1) {
                return String.format(template, "red", LoadState(value));
            } else if (value == 2) {
                return String.format(template, "blue", LoadState(value));
            } else {
                return String.format(template, "black", LoadState(value));

            }

           

        }
    </script>
    <script type="text/javascript">
        var addTab = function (tabPanel, id, url) {
            var tab = tabPanel.getComponent(id);

            if (!tab) {
                tab = tabPanel.add({
                    id: id,
                    title: url,
                    closable: true,
                    autoLoad: {
                        showMask: true,
                        url: url,
                        mode: "iframe",
                        maskMsg: "Loading " + url + "..."
                    }
                });

                tab.on("activate", function () {
                    var item = GridPanel1.items.get(id + "_item");

                    if (item) {
                        GridPanel1.setSelection(item);
                    }
                }, this);
            }

            tabPanel.setActiveTab(tab);
        }
    
                                
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="TopBarHolder" runat="Server">
    <ext:Toolbar ID="toolBar1" runat="Server">
        <Items>
            <ext:Button runat="server" ID="btnAdd" Text="Tạo công việc " Icon="PageAdd" Scale="Medium"
                CausesValidation="false">
                <DirectEvents>
                    <Click OnEvent="btnAdd_Click">
                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:ToolbarSeparator />
            <ext:Button runat="server" ID="btnEdit" Text="Sửa lỗi " Icon="Pencil" Scale="Medium"
                CausesValidation="false">
                <DirectEvents>
                    <Click OnEvent="btnEdit_Click">
                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:ToolbarSeparator />
            <ext:Button runat="server" ID="btnDelete" Text="Xóa lỗi " Icon="ApplicationDelete"
                Scale="Medium" CausesValidation="false">
                <DirectEvents>
                    <Click OnEvent="btnDelete_Click">
                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:ToolbarSeparator />
            <ext:Button runat="Server" ID="btnDuyet" Text="Duyệt lỗi" Icon="ApplicationLightning"
                Scale="Medium" CausesValidation="false">
                <Listeners>
                    <Click Handler="#{Window3}.show();" />
                </Listeners>
            </ext:Button>
            <ext:SplitButton runat="server" ID="btnTrash" Text="Thùng rác" Icon="Bin" Scale="Medium">
                <Menu>
                    <ext:Menu ID="Menu2" runat="server">
                        <Items>
                            <ext:MenuItem ID="MenuItem8" runat="server" Text="Xóa tất cả" Icon="Cancel">
                                <DirectEvents>
                                    <Click OnEvent="btnTrashEmpty_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                            <ext:MenuItem ID="MenuItem9" runat="server" Text="Xóa những bài được chọn" Icon="BinEmpty">
                                <DirectEvents>
                                    <Click OnEvent="btnTrashDelete_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                            <ext:MenuItem ID="MenuItem10" runat="server" Text="Bỏ khỏi thùng rác" Icon="ArrowTurnLeft">
                                <DirectEvents>
                                    <Click OnEvent="btnUnDelete_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                        </Items>
                    </ext:Menu>
                </Menu>
            
            </ext:SplitButton>
          
        </Items>
    </ext:Toolbar>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <ext:Store ID="Store1" runat="server" OnRefreshData="Store1_RefreshData" RemoteSort="true"
        RemotePaging="true">
        <Proxy>
            <ext:PageProxy />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ErrorID">
                <Fields>
                    <ext:RecordField Name="ErrorID" Type="Int" />
                    <ext:RecordField Name="ErrorName" Type="String" />
                    <ext:RecordField Name="DesOfCustomer" Type="String" />
                    <ext:RecordField Name="DateReport" Type="Date" />
                    <ext:RecordField Name="IsApproved" Type="Boolean" />
                    <ext:RecordField Name="IsAttach" Type="Boolean" />
                    <ext:RecordField Name="FilePath" Type="String" />
                    <ext:RecordField Name="IsDeleted" Type="Boolean" />
                    <ext:RecordField Name="StateError" Type="Int" />
                    <ext:RecordField Name="ProductCustomer_Customer_ContactName" Type="String" ServerMapping="ProductCustomer.Customer.ContactName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="limit" Value="10" Mode="Raw" />
            <ext:Parameter Name="sort" Value="" />
            <ext:Parameter Name="dir" Value="" />
        </BaseParams>
        <SortInfo Field="ErrorID" Direction="DESC" />
    </ext:Store>
   
    <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true" Title="Danh sách lỗi"
        Height="600" RowHeight="1.0" StoreID="Store1">
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:ImageCommandColumn Header="" Align="Center" Width="25" Resizable="false">
                    <Commands>
                        <ext:ImageCommand CommandName="MyCommand" Icon="Note" ToolTip-Text="Xem chi tiết">
                        </ext:ImageCommand>
                    </Commands>
                </ext:ImageCommandColumn>
                <ext:Column Header="Mã" DataIndex="ErrorID" Groupable="false" />
                <ext:Column Header="Tên lỗi" DataIndex="ErrorName" />
                <ext:Column Header="Miêu tả lỗi" DataIndex="DesOfCustomer" />
                <ext:DateColumn Header="Ngày báo lỗi" DataIndex="DateReport" Align="Center" Format="dd-mm-yyyy" />
                <ext:Column Header="File đính kèm" DataIndex="FilePath">
                    <Renderer Fn="LoadAttachs" />
                </ext:Column>
                <ext:Column Header="Trạng thái" DataIndex="StateError">
                    <Renderer Fn="LoadColor" />
                </ext:Column>
                <%--<ext:Column Header="Đã xóa" DataIndex="IsDeleted">
                    <Renderer Handler="return (value) ? 'Ðã xóa':'Chưa xóa';" />
                </ext:Column>--%>
            </Columns>
        </ColumnModel>
        <Listeners>
            <Command Handler="Ext.net.DirectMethods.LoadErrors(record.data.ErrorID);" />
        </Listeners>
        <SelectionModel>
            <ext:CheckboxSelectionModel runat="Server">
                
            </ext:CheckboxSelectionModel>
        </SelectionModel>
        <View>
            <ext:GroupingView ID="GroupingView1" runat="server" ForceFit="true" MarkDirty="false"
                ShowGroupName="true" EnableNoGroups="true" HideGroupedColumn="true" ShowGroupsText="Nhóm lại theo cột này" />
        </View>
        <LoadMask ShowMask="true" />
        <Plugins>
            <ext:GridFilters runat="server" ID="GridFilters1">
                <Filters>
                    <ext:NumericFilter DataIndex="ErrorID" />
                    <ext:StringFilter DataIndex="ErrorName" />
                    <ext:StringFilter DataIndex="DesOfCustomer" />
                    <ext:BooleanFilter DataIndex="IsChecked" />
                    <ext:DateFilter DataIndex="DateRepport" />
                    <ext:BooleanFilter DataIndex="IsAttach" />
                </Filters>
            </ext:GridFilters>
            <ext:RowExpander runat="Server">
                <Template runat="Server">
                    <Html>
                        <p><b>Tên công ty</b></p>
                        <p>{ProductCustomer_Customer_ContactName}</p>
                        <p><b>Miêu tả của khách hàng : </b></p>
                        <br />
                        <p>{DesOfCustomer}</p>
                        <br />
                    </Html>
                </Template>
            </ext:RowExpander>
        </Plugins>
        <BottomBar>
            <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="10" />
        </BottomBar>
    </ext:GridPanel>
    <uc:ErrorAddEdit ID="errorAdd1" runat="Server" ReloadGrid="GridPanel1" />
    <uc:WorkAddEdit ID="workAddEdit1" runat="Server" ReloadGrid="GridPanel1" />

    <ext:Window ID="wProductDetail" runat="Server"  Title="Chi tiết sản phẩm lỗi "
        Collapsible="true" Icon="ApplicationViewDetail" Width="900" Height="500" AutoScroll="true"
        Hidden="true" ButtonAlign="Center" AutoDataBind="false" Modal="true" Maximizable="true">

        <AutoLoad ShowMask="true" Mode="IFrame" />
    </ext:Window>

    
    <ext:Window ID="Window3" runat="server" Collapsible="true" Icon="Application" Title="Duyệt lỗi"
         AutoScroll="true" Height="200" Hidden="true" Width="320">
        <Content>
            <ext:Panel ID="Panel1" runat="Server" ButtonAlign="Center" Layout="FormLayout" LabelWidth="50" Width="300">

                <Items>
                    <ext:Label runat="Server" Text="Chọn trạng thái lỗi" />
                    <ext:ComboBox ID="cbxState" runat="Server" Width="200" >
                        <Items>
                            <ext:ListItem Text="Chưa duyệt" Value="1" />
                            <ext:ListItem Text="Đã duyệt" Value="2" />
                            <ext:ListItem Text="Đã xử lý xong" Value="3" />
                        </Items>
                    </ext:ComboBox>
                </Items>
                <Buttons>
                    <ext:Button runat="server" ID="btnSetState" Text="Cập nhật">
                        <DirectEvents>
                            <Click OnEvent="btnSetState_Click" />
                        </DirectEvents>
                    </ext:Button>
                    <ext:Button ID="Button1" runat="Server" Text="Bỏ qua">
                        <Listeners>
                            <Click Handler="#{Window3}.hide();" />
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:Panel>
        </Content>
    </ext:Window>

 
</asp:Content>
